<script setup>
import {onMounted, ref} from "vue";
  import {useRoute} from "vue-router";
import EditTestCom from "@/components/teacher/edittest/EditTestCom.vue";
import EditSelectCom from "@/components/teacher/edittest/EditSelectCom.vue";
import EditAtricleCom from "@/components/teacher/edittest/EditAtricleCom.vue";
import EditGapCom from "@/components/teacher/edittest/EditGapCom.vue";
import EditClozeCom from "@/components/teacher/edittest/EditClozeCom.vue";
import EditTranCom from "@/components/teacher/edittest/EditTranCom.vue";
import EditWritingCom from "@/components/teacher/edittest/EditWritingCom.vue";
import EditPreCom from "@/components/teacher/edittest/EditPreCom.vue";
import EditCorrectCom from "@/components/teacher/edittest/EditCorrectCom.vue";

  const tmpTest = [
    {
      "id": 1,
      "category": "单项选择",
      "problem": "We feel quite sad about\ndeath of Yuan Longping,“Father of Hybrid Rice\". What\ngreat loss it is!\n",
      "answer": "B",
      "sonProID": "",
      "score": 0,
      "choiceNum": 3,
      "teacherID": 0,
      "star": 0,
      "choice1": "A. the; /",
      "choice2": "B.a; the",
      "choice3": "C.a; the",
      "choice4": "D.a; the",
      "content": null,
      "sonExercise": null,
      "public": false,
      "single": true
    },
    {
      "id": 5,
      "category": "翻译",
      "problem": "Translate the following sentences into English",
      "answer": "\r\n\r\nTranslation:\r\nNear my home, there is a beautiful park where I often take walks. The park is filled with tall trees, colorful flowers, and a clear stream. Every time I enter the park, I feel the fresh air, as if leaving all worries behind. I enjoy strolling in the park, admiring the beauty of nature, and listening to the birds' songs. Sometimes, I find a quiet corner, sit down, and read a book or contemplate life. The park is a great place for me to relax and free my mind. Every time I leave the park, I feel refreshed and energized.",
      "sonProID": null,
      "score": 0,
      "choiceNum": 0,
      "teacherID": 0,
      "star": 0,
      "choice1": null,
      "choice2": null,
      "choice3": null,
      "choice4": null,
      "content": "我家附近有一个美丽的公园，我经常在那里散步。公园里有高大的树木，五彩斑斓的花朵，还有清澈的小溪。每当我走进公园，都会感受到一股清新的空气，仿佛所有的烦恼都被抛在了身后。我喜欢在公园里漫步，欣赏大自然的美丽，聆听鸟儿的歌唱。有时，我会找一个安静的角落，坐下来读书或者思考人生。公园是我放松心情，放飞思绪的好地方。每次离开公园，我都感到心情舒畅，充满了活力。",
      "sonExercise": null,
      "public": false,
      "single": true
    },
    {
      "id": 6,
      "category": "作文",
      "problem": "Please write an essay of no less than 150 words ",
      "answer": "The sun was just beginning to rise as we set out on our journey. It was a trip I had been eagerly anticipating for months – a trek through the lush greenery of the Amazon rainforest. As we ventured deeper into the wilderness, I couldn't help but marvel at the sheer beauty and untamed majesty of nature surrounding us.\r\n\r\nOur days were filled with thrilling encounters and unforgettable experiences. We navigated through dense foliage, crossed rushing rivers on rickety bridges, and climbed towering trees to catch glimpses of exotic birds and monkeys swinging from branch to branch. Each moment was an adventure, each sight a wonder to behold.\r\n\r\nOne particular memory stands out among the rest – the night we spent camping deep in the heart of the rainforest. As darkness fell and the sounds of the jungle came alive around us, we gathered around a crackling campfire, sharing stories and laughter under a blanket of stars. It was a moment of pure magic, one that will stay with me forever.\r\n\r\nBut amidst the beauty and excitement, there were also challenges to overcome. We faced sweltering heat, relentless mosquitoes, and the occasional downpour that left us drenched to the bone. Yet, each obstacle only served to strengthen our bond as a group and deepen our appreciation for the rugged beauty of the Amazon.\r\n\r\nOne unforgettable journey I embarked on was a trip to the breathtaking landscapes of Iceland. From the moment I set foot on its soil, I was captivated by its raw beauty. We explored volcanic landscapes, glistening glaciers, and cascading waterfalls. The highlight was witnessing the dancing Northern Lights painting the night sky with vibrant hues of green and purple. Each day brought new adventures, from soaking in natural hot springs to hiking along rugged coastlines. But it wasn't just the scenery that left a lasting impression; it was the warmth of the Icelandic people and their rich culture that truly made the trip unforgettable. As I bid farewell to this enchanting land, I carried with me memories that would last a lifetime.",
      "sonProID": null,
      "score": 0,
      "choiceNum": 0,
      "teacherID": 0,
      "star": 0,
      "choice1": null,
      "choice2": null,
      "choice3": null,
      "choice4": null,
      "content": "描述一次难忘的旅行经历。",
      "sonExercise": null,
      "public": false,
      "single": true
    },
    {
      "id": 7,
      "category": "单项选择",
      "problem": "Caoxian county- _______ tiny lttle-known inland county in\nEast China's Shandong\nProvince, became famous overnight.\n",
      "answer": "C",
      "sonProID": null,
      "score": 0,
      "choiceNum": 3,
      "teacherID": 0,
      "star": 0,
      "choice1": "A.a; the",
      "choice2": "B.a; /",
      "choice3": "C.the; at",
      "choice4": "D.the; /",
      "content": null,
      "sonExercise": null,
      "public": false,
      "single": true
    },
    {
      "id": 4,
      "category": "阅读",
      "problem": "Whose birthday is it?\n",
      "answer": "C",
      "sonProID": "2,3",
      "score": 0,
      "choiceNum": 4,
      "teacherID": 0,
      "star": 0,
      "choice1": "A. Rose's ",
      "choice2": "B. David's",
      "choice3": "C. Rose'",
      "choice4": "D.mother's ",
      "content": "David is eight. One day his friend Rose says to him, \"This Sunday is my birthday. Can y\nou come to my birthday party?\" David says, \"Yes.\"\nOn Sunday, David asks his mother if he can go to the party. His mother says, \"Yes, you \ncan go, but you must be polite. Don't ask for any food. They will give you some.\" \"All right,\nMum.\" David answers and he goes to Rose's house on his bike.\nThere are lots of kids at the party. They play together for some time, and then Rose's m\nother gives them some food, but she forgets David. He waits and waits and then he takes h\nis plate up and asks, \"Do you want a nice clean plate?\"\n",
      "sonExercise": [
        {
          "id": 2,
          "category": "阅读",
          "problem": "The birthday party is in .\n",
          "answer": "B",
          "sonProID": null,
          "score": 0,
          "choiceNum": 4,
          "teacherID": 0,
          "star": 0,
          "choice1": "A. Rose's ",
          "choice2": "B. David's",
          "choice3": "C. Rose'",
          "choice4": " D.mother's ",
          "content": null,
          "sonExercise": null,
          "public": false,
          "single": false
        },
        {
          "id": 3,
          "category": "阅读",
          "problem": "David goes to the party\n",
          "answer": "A",
          "sonProID": null,
          "score": 0,
          "choiceNum": 4,
          "teacherID": 0,
          "star": 0,
          "choice1": "A. Rose's ",
          "choice2": "B. David's",
          "choice3": "C. Rose'",
          "choice4": " D.mother's ",
          "content": null,
          "sonExercise": null,
          "public": false,
          "single": false
        }
      ],
      "public": false,
      "single": false
    },
    {
      "id": 10,
      "category": "阅读",
      "problem": "\nWhose birthday is it?",
      "answer": "C",
      "sonProID": "8,9",
      "score": 0,
      "choiceNum": 4,
      "teacherID": 0,
      "star": 0,
      "choice1": "A. Rose's ",
      "choice2": "B. David's",
      "choice3": "C. Rose'",
      "choice4": " D.mother's ",
      "content": "David is eight. One day his friend Rose says to him, \"This Sunday is my birthday. Can y\nou come to my birthday party?\" David says, \"Yes.\"\nOn Sunday, David asks his mother if he can go to the party. His mother says, \"Yes, you \ncan go, but you must be polite. Don't ask for any food. They will give you some.\" \"All right,\nMum.\" David answers and he goes to Rose's house on his bike.\nThere are lots of kids at the party. They play together for some time, and then Rose's m\nother gives them some food, but she forgets David. He waits and waits and then he takes h\nis plate up and asks, \"Do you want a nice clean plate?\"",
      "sonExercise": [
        {
          "id": 8,
          "category": "阅读",
          "problem": "The birthday party is in .",
          "answer": "B",
          "sonProID": null,
          "score": 0,
          "choiceNum": 4,
          "teacherID": 0,
          "star": 0,
          "choice1": "A. Rose's ",
          "choice2": "B. David's",
          "choice3": "C. Rose'",
          "choice4": " D.mother's ",
          "content": "",
          "sonExercise": null,
          "public": false,
          "single": false
        },
        {
          "id": 9,
          "category": "阅读",
          "problem": "David goes to the party",
          "answer": "A",
          "sonProID": null,
          "score": 0,
          "choiceNum": 4,
          "teacherID": 0,
          "star": 0,
          "choice1": "A. Rose's ",
          "choice2": "B. David's",
          "choice3": "C. Rose'",
          "choice4": " D.mother's ",
          "content": null,
          "sonExercise": null,
          "public": false,
          "single": false
        }
      ],
      "public": false,
      "single": false
    }
  ]
  onMounted(()=>{
    const route = useRoute()
    const pageParams = route.query
    console.log(pageParams)
  })

  /*
  套题
   */
  //套题参数
  const testPrams = ref({
    id:null,
    name: '组卷1',//8字
    detail:'这是一个示例组卷',//30字
    startTime: '2023/12/21 12:00',
    endTime: '2023/12/22 12:00',
    timeLimit: 120,
    aiUse: false,
    totalScore: 160,
    xuanzeNum: 5,
    xuanzeScore: 2,
    yueduArticleNum: 3,
    yueduNum: 12,
    yueduScore: 5,
    xuanciArticleNum: 1,
    xuanciNum: 20,
    xuanciScore:2,
    wanxingArticleNum: 1,
    wanxingNum: 10,
    wanxingScore: 1,
    gaicuoArticleNum: 1,
    gaicuoNum: 10,
    gaicuoScore: 1,
    fanyiNum: 2,
    fanyiScore: 10,
    zuowenNum: 1,
    zuoWenScore: 20
  })
  const updateTestPrams = (newValue)=>{
    testPrams.value = newValue
  }
  //选择题组
  const xuanzeParams = ref({
    quesNum: 5,
    quesScore: 2,
    ques: [
      {
        id: 4,
        category: "单项选择",
        problem: "We feel quite sad about\ndeath of Yuan Longping,“Father of Hybrid Rice\". What\ngreat loss it is!\n",
        answer: "B",
        sonProID: "",
        score: 0,
        choiceNum: 3,
        teacherID: 0,
        star: 0,
        choice1: "A. the; /",
        choice2: "B.a; the",
        choice3: "C.a; the",
        choice4: "D.a; the",
        content: null,
        sonExercise: null,
        public: false,
        single: true
      },
      {
        id: 8,
        category: "单项选择",
        problem: "We feel quite sad about\ndeath of Yuan Longping,“Father of Hybrid Rice\". What\ngreat loss it is!\n",
        answer: "B",
        sonProID: "",
        score: 0,
        choiceNum: 3,
        teacherID: 0,
        star: 0,
        choice1: "A. the; /",
        choice2: "B.a; the",
        choice3: "C.a; the",
        choice4: "D.a; the",
        content: null,
        sonExercise: null,
        public: false,
        single: true
      }
    ]
  })
  const updateXuanzeParams = (newValue)=>{
    xuanzeParams.value = newValue
  }
  //


  /*
  菜单
   */
  const menuIndex = ref('1')
  const handleMenuSelect = (newIndex)=>{
    menuIndex.value = newIndex
  }
  /*
  习题组设置
   */


</script>

<template>
  <div class="container">
    <!--菜单-->
    <el-menu
        :default-active="menuIndex"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleMenuSelect"
    >
      <el-menu-item style="color: #3e95ec; font-weight: bold">编辑习题组</el-menu-item>
      <el-menu-item index="1">习题组设置</el-menu-item>
      <el-sub-menu index="2">
        <template #title>题目设置</template>
        <el-menu-item index="2-1">单项选择</el-menu-item>
        <el-menu-item index="2-2">阅读理解</el-menu-item>
        <el-menu-item index="2-3">选词填空</el-menu-item>
        <el-menu-item index="2-4">完形填空</el-menu-item>
        <el-menu-item index="2-5">短文改错</el-menu-item>
        <el-menu-item index="2-6">翻译</el-menu-item>
        <el-menu-item index="2-7">作文</el-menu-item>
      </el-sub-menu>
      <el-menu-item index="9">预览</el-menu-item>
      <div class="sure-btn-container">
        <el-menu-item index="10" class="sure-btn">确定</el-menu-item>
      </div>
    </el-menu>
    <!--具体组件-->
    <EditTestCom :testParams="testPrams" @update:message="updateTestPrams" class="com-style" v-if="menuIndex === '1'"/>
    <EditSelectCom :xuanzeParams="xuanzeParams" @update:xuanzeParams="updateXuanzeParams" class="com-style" v-if="menuIndex === '2-1'"/>
    <EditAtricleCom class="com-style" v-if="menuIndex === '2-2'"/>
    <EditGapCom class="com-style" v-if="menuIndex === '2-3'"/>
    <EditClozeCom class="com-style" v-if="menuIndex === '2-4'"/>
    <EditCorrectCom class="com-style" v-if="menuIndex === '2-5'"/>
    <EditTranCom class="com-style" v-if="menuIndex === '2-6'"/>
    <EditWritingCom class="com-style" v-if="menuIndex === '2-7'"/>
    <EditPreCom class="com-style" v-if="menuIndex === '3'"/>
  </div>
</template>

<style scoped>
  .container{
    display: flex;
    flex-direction: column;
  }
  .com-style{
    width: 100%;
    flex: 1;
  }
  .sure-btn-container{
    display: flex;
    align-items: center;
    justify-content: right;
    flex: 1;
  }
  .sure-btn{

  }
</style>